package nz.ac.massey.se.Q4;

import org.apache.log4j.*;

public class Logging {

    /**
     * Q4: Logging
     *
     * @author  Charles Zheng
     * @id 19029962
     */

    private final static Logger log = Logger.getLogger("mylogger");

    public static void main(String[] args) {
        //TODO:
        ConsoleAppender console = new ConsoleAppender(); //create appender
        //configure the appender
        String PATTERN = "[%t] %p %c - %m%n";
        console.setLayout(new PatternLayout(PATTERN));
        console.setThreshold(Level.DEBUG);
        console.activateOptions();
        Logger.getRootLogger().addAppender(console);

        FileAppender fa = new FileAppender();
        fa.setName("FileLogger");
        fa.setFile("Q4B.html");
        fa.setLayout(new HTMLLayout());
        fa.setThreshold(Level.DEBUG);
        fa.setAppend(true);
        fa.activateOptions();
        Logger.getRootLogger().addAppender(fa);

        log.debug("debug 2");
        log.fatal("big issue 1");
        log.info("info 2");
        log.debug("debug 3");
        log.fatal("big issue");
        log.warn("warning 2");
        log.error("error 1");
        log.error("error 2");
    }
}
